'''
Created on 14-Jul-2009

@author: dexen
'''

import rpyc

def test():
    print "I am client"

def arrived(res):
    print res
    print "arrived"

if __name__ == "__main__":
    #x = rpyc.connect_by_service("TEST", "localhost")
    #x = rpyc.connect("localhost", port=10000)
    #print x.root.get_service_name()
    x = rpyc.connect_by_service(service_name="TEST")
    #x.root.get_service_name()
    
    #x.root.register_func(test)
    
    #x.root.test()
    
    wrapper = rpyc.async(x.root.test)
    
    
    res = wrapper()
    
    print res
    
    
    res.add_callback(arrived)
    
    while not res.ready:
        pass
    print "it is ready"
